<!--#include file="functions.asp" -->

<% 
   'set cn=Server.CreateObject("ADODB.Connection")
   'cn.Open "MP2ENTTEST2", "MP2", "MP2"
   dim sql
   
   '---------------- update EXIREG
   sql = "UPDATE EXILVOHEADER SET "
   if (request("IsUc")="Y") then
   sql = sql & " ROUTEUSER='FINANCE'," 
   sql = sql & " UCCODE=''," 
   else
   sql = sql & " ROUTEUSER='" & request("UC")& "',"
   end if
   'sql = sql & " UPDATEUSER='" & empCode & "',"
   sql = sql & " STATUS='REJECTED',"
   sql = sql & " COMMENTS='" & dblq(request("Notes"))&"'"
   'sql = sql & " UPDATESTAMP=GETDATE()"
   sql = sql & " WHERE LVONUM='" & request("seqnum2") & "'"
   
   cn.execute(sql)

'cn.close


   if (request("IsUc")="Y") then
      sRecipients =GetLoginName(request("recBy"))
	  'sRecipients = "DKusnadi@Premier-Oil.com;BKoernianto@Premier-Oil.com"
   else
	  sRecipients = getloginname(request("UC"))
	  'sCCList = "MAgus@Premier-Oil.com"
   end if

    sDomainName = "@Premier-oil.com"
	EmailSubject = "Electronic Invoice Approval"  
	EmailBody = "<HTML><HEAD><TITLE></TITLE></HEAD><BODY>"
	EmailBody = EmailBody & "<FONT face=Arial size=2>Dear Sir/Madame, </font><BR><BR>"
	EmailBody = EmailBody & "<FONT face=Arial size=2>" & usrFullName & " has rejected the following invoice: </font><BR><BR>"
	EmailBody = EmailBody & "<FONT face=Arial size=2>Vendor Name: " & request("VendorName") & "</font><BR>"
	EmailBody = EmailBody & "<FONT face=Arial size=2>Invoice No: " & request("InvoiceNo") & "</font><BR>"
	EmailBody = EmailBody & "<FONT face=Arial size=2><b><a href='"& theURL& "/Inv_DetailLVO.asp?LVONum=" &  request("seqnum")  & "'>Click here for Invoice detail</a></b></font><BR><BR>"
	EmailBody = EmailBody & "<FONT face=Arial size=2>Thank you </font><BR><BR>"
	EmailBody = EmailBody & "<FONT face=Arial size=2><b>" & usrFullName &"</b></font>"	
	
	EmailBody = EmailBody & "</BODY></HTML>"
	
	dim MyBody
	MyBody = ReformatText(EmailBody)
	SendCDOEmail sRecipients, sCCList, "", usrName & sDomainName, EmailSubject, MyBody

'back to approval page

response.redirect "my_Invoice.asp"

%>
